<template>
  <div>
    <el-drawer title="推荐知识库文档" :visible.sync="drawer" :direction="direction" size="50%">
      <div class="docs-table">
        <el-row>
          <el-table :data="list">
            <el-table-column label="文档类型" align="center" prop="verno" width="140">
              <template slot-scope="scope">
                {{ getDocType(scope.row.type) }}
              </template>
            </el-table-column>
            <el-table-column label="文档标题" prop="title" />
            <el-table-column label="更新时间" align="center" prop="time" width="180" />
            <el-table-column label="操作" align="center" width="100">
              <template slot-scope="scope">
                <el-button size="mini" type="text" @click="handleDocView(scope.row)">查看文档 </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-row>

        <el-row>
          <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
        </el-row>
      </div>
    </el-drawer>
    <covenant-detail ref="convenantDetail" />
    <doc-detail ref="docDetail" />
    <law-detail ref="lawDetail" />
    <management-system-detail ref="managementSystemDetail" />
    <standard-detail ref="standardDetail" />
    <common-detail ref="commonDetail" />
  </div>
</template>
<script>
import { docSearchPage } from "@/api/kno/doc";
import CovenantDetail from "@/views/kno/components/covenantDetail.vue";
import DocDetail from "@/views/kno/components/docDetail.vue";
import LawDetail from "@/views/kno/components/lawDetail.vue";
import ManagementSystemDetail from "@/views/kno/components/managementsystemDetail.vue";
import StandardDetail from "@/views/kno/components/standardDetail.vue";
import CommonDetail from "@/views/kno/components/commonDetail.vue";
export default {
  name: "MatchDocs",
  components: {
    CovenantDetail,
    DocDetail,
    LawDetail,
    ManagementSystemDetail,
    StandardDetail,
    CommonDetail,
  },
  data() {
    return {
      drawer: false,
      direction: "rtl",
      list: [],
      queryParams: {
        pageNum: 1,
        pageSize: 15,
      },
      total: 0,
    };
  },
  mounted() {},
  methods: {
    show() {
      this.getList();
      this.drawer = true;
    },
    getList() {
      // docSearchPage("应急", this.queryParams).then(res => {
      //   this.list = res.rows;
      //   this.total = res.total;
      // });
    },
    handleDocView(data) {
      switch (data.type) {
        case "covenant":
          this.$refs.convenantDetail.show(data.id);
          break;
        case "doc":
          this.$refs.docDetail.show(data.id);
          break;
        case "law":
          this.$refs.lawDetail.show(data.id);
          break;
        case "managementsystem":
          this.$refs.managementSystemDetail.show(data.id);
          break;
        case "standard":
          this.$refs.standardDetail.show(data.id);
          break;
        case "common":
          this.$refs.commonDetail.show(data.id);
          break;
      }
    },
    getDocType(type) {
      let mimes = [
        { label: "案例库", value: "case" },
        { label: "国际民航公约", value: "covenant" },
        { label: "知识库文档", value: "doc" },
        { label: "法律法规", value: "law" },
        { label: "管理制度", value: "managementsystem" },
        { label: "标准规范", value: "standard" },
        { label: "应急常识", value: "common" },
      ];
      let mime = mimes.find(val => val.value == type);
      return mime.label;
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep {
  .el-drawer.rtl {
    background-color: #00356b;

    .el-drawer__header {
      color: white;
    }
  }
}

.docs-table {
  padding: 0 20px;
}
</style>
